<?php
// Funktion zum Registrieren von Dateitypen
$media_func_register = array();
function mediaRegisterFunc($filetyp, $function, $type="thumb")
{
  global $media_func_register;
  if(is_string($filetyp)) {
    $filetyp = array($filetyp);
  }
  if($type!="thumb" && $type!="big") {
    $type = "thumb";
  }
  foreach($filetyp as $t) {
    $media_func_register[$type][$t] = $function;
  }
}
// Funktion zum Zurueckgeben von Dateitypen
function mediaGetThumbnailImage($file="")
{
  global $media_func_register;
  
  if(empty($file)) {
    return "<img src=\"css/images/folderbig.png\" style=\"height: 48px;\" alt=\"Ordner\" />";
  }
  
  $t = strtolower(extractFileTyp($file));
  if(isset($media_func_register['thumb'][$t])) {
    return call_user_func_array($media_func_register['thumb'][$t], $file);
  }
  return "<img src=\"css/images/folderbig.png\" style=\"height: 48px;\" alt=\"Ordner\" />";
}  
// Funktion zum Registrieren von Dokumenttypen
$media_docu_register = array();
function mediaRegisterDocu($filetyp, $name, $title="")
{
  global $media_docu_register;
  if(is_string($filetyp)) {
    $filetyp = array($filetyp);
  }
  $media_docu_register[md5($name)] = array($name, $title, $filetyp);
}
// Hole Dateitypen
foreach(createFileList(dirname(__FILE__)."/filetypes/") as $f) {
  include_once("filetypes/".$f);
}

$media_checkout = array();
$media_checkout2 = array();
$media_checkout_count = 0;
$media_checkout_size = 0;
function mediaCheckout($verz)
{
  global $media_checkout;
  global $media_checkout2;
  global $media_checkout_count;
  global $media_checkout_size;
  
  foreach(createFileList($verz) as $f) {
    if(!isset($media_checkout[extractFileTyp($f)])) {
      $media_checkout[extractFileTyp($f)] = array();
    }
    $media_checkout_count++;
    $media_checkout_size += filesize($verz.$f);
    $media_checkout[extractFileTyp($f)][] = array($f, $verz.$f, filesize($verz.$f), $verz);
    $media_checkout2[md5(strtolower($f))] = array($f, $verz.$f, filesize($verz.$f), $verz);
  }
  
  foreach(createFolderList($verz) as $f) {
    $media_checkout2[md5(strtolower($f))] = array($f, $verz.$f);
    mediaCheckout($verz.$f."/");
  }
}

mediaCheckout($media_dir.$showfolder);
?>